<template>
    <div class="filter-container">
      <span>{{ remaining }} 项未完成</span>
      <div class="filter-buttons">
        <button
          v-for="filter in filters"
          :key="filter"
          @click="$emit('set-filter', filter)"
          :class="{ active: visibility === filter }"
        >
          {{ filterLabels[filter] }}
        </button>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    name: 'TodoFilter',
    props: {
      remaining: Number,
      visibility: String
    },
    data() {
      return {
        filters: ['all', 'active', 'completed'],
        filterLabels: {
          all: '全部',
          active: '未完成',
          completed: '已完成'
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .filter-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    color: #666;
    font-size: 0.9rem;
  }
  
  .filter-buttons button {
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
  }
  
  .filter-buttons button:hover {
    border-color: #ddd;
  }
  
  .filter-buttons button.active {
    border-color: #42b983;
    color: #42b983;
  }
  </style>